package rest_api

import (
	"scheduler/config"

	log "github.com/omidnikta/logrus"
	"gopkg.in/gin-gonic/gin.v1"
)

var (
	router = gin.Default()
)

func init() {
	var (
		addr    string
		profile bool
	)

	err := config.Get("http:profile", &profile)
	if nil != err {
		log.Fatalln(err)
	}

	err = config.Get("http:addr", &addr)
	if nil != err {
		log.Fatalln(err)
	}

	router.GET("/job", _jobHandler.Read)
	router.POST("/job", _jobHandler.Create)
	router.PUT("/job", _jobHandler.Update)
	router.DELETE("/job", _jobHandler.Delete)

	go router.Run(addr)

}
